package com.itheima.service.impl;

import com.itheima.domain.entity.ClazzStudentCountInfo;
import com.itheima.domain.entity.JobStatistics;
import com.itheima.domain.vo.EachClassStudentCount;
import com.itheima.domain.vo.GenderInfo;
import com.itheima.domain.vo.JobOption;
import com.itheima.domain.vo.StudentDegreeInfo;
import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:篍
 * @Date: 2025/07/14 16:37
 * @Description:
 */
@Slf4j
@Service
public class ReportServiceImpl implements ReportService {


    @Autowired
    EmpMapper empMapper;

    @Autowired
    StudentMapper studentMapper;

    @Override
    public JobOption getEmpJobData() {
        List<JobStatistics> jobInfo= empMapper.getEmpJobData();
        JobOption jobOption=new JobOption();
        jobOption.setJobList(jobInfo.stream().map(JobStatistics::getPos).toList());
        jobOption.setDataList(jobInfo.stream().map(JobStatistics::getNum).toList());
        return jobOption;
    }

    @Override
    public List<GenderInfo> getGenderData() {
        return empMapper.getGenderData();
    }

    /**
     * 学员学历统计
     */
    @Override
    public List<StudentDegreeInfo> studentDegreeReport() {
       return studentMapper.studentDegreeReport();
    }

    /**
     * 班级人数统计
     * @return
     */
    @Override
    public EachClassStudentCount studentCountReport() {
       List<ClazzStudentCountInfo> clazzStudentCountInfos = studentMapper.studentCountReport();
       log.warn("clazzStudentCountInfos={}",clazzStudentCountInfos);
       List<String> clazzList = clazzStudentCountInfos.stream().map(ClazzStudentCountInfo::getClazzName).toList();
       List<Long> dataList = clazzStudentCountInfos.stream().map(ClazzStudentCountInfo::getStudentNum).toList();
       log.warn("dataList={}",dataList);
       return new EachClassStudentCount(clazzList,dataList);
    }
}
